import { Component, OnInit } from '@angular/core';
import { NzMessageService } from 'ng-zorro-antd/message';
import { ActivatedRoute } from '@angular/router';

@Component({
    selector: 'app-warehouse-goods-add',
    templateUrl: './warehouse-goods-add.component.html',
    styleUrls: ['./warehouse-goods-add.component.scss']
})
export class WarehouseGoodsAddComponent implements OnInit {

    messageId: string = "";
    //路由参数
    routeParams: any = {}
    // 选中当前页面的下标
    selectedIndex: any = 0
    // 缓存bom 单数据
    bomList: any = []
    detailsParams: any = {};


    constructor(
        private message: NzMessageService,
        private activatedRoute: ActivatedRoute,
    ) { }

    ngOnInit() {
        this.activatedRoute.params.subscribe((params) => {
            this.routeParams = params
        })
    }
    // 监听 tab 事件
    onSelectChangeTab(val: any) {
        this.selectedIndex = val
    }
    changeBomList(list: any) {
        this.bomList = list
    }
    changeParams(res: any) {
        this.detailsParams = res;
    }
    /**
     * 开启loading
     */
    createBasicMessage(): void {
        this.messageId = this.message.loading('正在请求...', { nzDuration: 0 }).messageId;
    }
    /**
     * 移除loading
     */
    removeBasicMessage() {
        this.message.remove(this.messageId);
        this.messageId = "";
    }
    /**
     * 全局展示操作反馈信息
     * @param type 其他提示类型 success:成功 error:失败 warning：警告
     */
    createMessage(type: any, str: any): void {
        this.message.create(type, str);
    }
}
